package com.hw.common.utils;

import org.apache.catalina.core.ApplicationPushBuilder;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author lipeng
 * @description context
 * @date 2023/3/7 10:25
 */
@Component
public class ApplicationContextUtil implements ApplicationContextAware {
    private static ApplicationContext application;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        application = applicationContext;
    }

    public static Object getBean(String name){
        return getApplicationContext().getBean(name);
    }

    public static ApplicationContext getApplicationContext() {
        return application;
    }
}
